﻿<phone:PhoneApplicationPage 
    x:Class="CarBloke.Pages.VehicleLogPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"       
    xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"     
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:local="clr-namespace:CarBloke"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    mc:Ignorable="d" d:DesignHeight="696" d:DesignWidth="480"
    shell:SystemTray.IsVisible="True">
    
    <!--LayoutRoot contains the root grid where all other page content is placed-->
    <Grid x:Name="LayoutRoot" Background="Transparent">        
        <Grid.Resources>
            <DataTemplate x:Key="listItemTemplate">
                <Grid Margin="0,0,0,13">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width=".3*"/>
                        <ColumnDefinition Width=".4*"/>
                        <ColumnDefinition Width=".3*"/>
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="*"/>
                    </Grid.RowDefinitions>

                    <!-- Magic sauce text block because of width bug in a list box-->
                    <TextBlock Grid.ColumnSpan="3" Height="1" Text="                                                                                                                       "/>
                    
                    <!-- Fuel quantity, time/miles since oil change, or description-->
                    <TextBlock Grid.Row="0" Grid.Column="0" HorizontalAlignment="Left" Text="{Binding Row0Column0}" Style="{StaticResource PhoneTextTitle3Style}" Grid.ColumnSpan="3"/>
                    <TextBlock Grid.Row="0" Grid.Column="1" HorizontalAlignment="Center" Text="{Binding Row0Column1}" Style="{StaticResource PhoneTextTitle3Style}"/>
                    <TextBlock Grid.Row="0" Grid.Column="1" Grid.ColumnSpan="2" HorizontalAlignment="Right" Text="{Binding Row0Column2}" Style="{StaticResource PhoneTextSmallStyle}"/>

                    <!-- Date, odometer, and cost -->
                    <TextBlock Grid.Row="1" Grid.Column="0" HorizontalAlignment="Left" Text="{Binding Row1Column0}" Style="{StaticResource PhoneTextSmallStyle}"/>
                    <TextBlock Grid.Row="1" Grid.Column="1" HorizontalAlignment="Center" Text="{Binding Row1Column1}" Style="{StaticResource PhoneTextSmallStyle}"/>
                    <TextBlock Grid.Row="1" Grid.Column="2" HorizontalAlignment="Right" Text="{Binding Row1Column2}" Style="{StaticResource PhoneTextSmallStyle}"/>                    

                    <!-- Notes on the 3rd row, if notes exist-->
                    <TextBlock Grid.Row="2" Grid.Column="0" HorizontalAlignment="Left" Text="{Binding Row2Column0}" Style="{StaticResource PhoneTextAccentStyle}" Visibility="{Binding Path=Row2Column0, Converter={StaticResource StringToVisbilityConverter}}" Grid.ColumnSpan="3"/>
                </Grid>
            </DataTemplate>
        </Grid.Resources>

        <controls:Pivot x:Name="PivotControl" Title="{Binding Path=Strings.ApplicationTitle, Source={StaticResource LanguageProvider}}">
            <controls:PivotItem x:Name="FuelPivotItem" Header="{Binding Path=Strings._fuel, Source={StaticResource LanguageProvider}}">
                <ListBox x:Name="FuelLogEntryListBox" SelectionChanged="LogEntryListBox_SelectionChanged" ItemTemplate="{StaticResource listItemTemplate}"/>
            </controls:PivotItem>
            <controls:PivotItem x:Name="OilPivotItem"  Header="{Binding Path=Strings._oil, Source={StaticResource LanguageProvider}}">
                <ListBox x:Name="OilLogEntryListBox" SelectionChanged="LogEntryListBox_SelectionChanged" ItemTemplate="{StaticResource listItemTemplate}"/>
            </controls:PivotItem>
            <controls:PivotItem x:Name="MaintenancePivotItem"  Header="{Binding Path=Strings._other, Source={StaticResource LanguageProvider}}">
                <ListBox x:Name="MaintenanceLogEntryListBox" SelectionChanged="LogEntryListBox_SelectionChanged" ItemTemplate="{StaticResource listItemTemplate}"/>
            </controls:PivotItem>
        </controls:Pivot>        
    </Grid>

    <!-- ApplicationBar -->
    <phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
            <shell:ApplicationBarIconButton x:Name="appbar_newLogButton" IconUri="/Images/AppBar/add.png" Text="new" Click="appbar_newLogButton_Click"></shell:ApplicationBarIconButton>
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>

</phone:PhoneApplicationPage>
